package cn.wolfcode.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

@Setter
@Getter
public class Appointment {
    private Long id2;

    public static final int STATUS_TYPE_APPOINT = 0;  //预约中、预约中 待确定
    public static final int STATUS_TYPE_PERFORM = 1;  //履行中
    public static final int STATUS_TYPE_CONSUME = 2;  //消费中
    public static final int STATUS_TYPE_PLACEON = 3;  //归档中
    public static final int STATUS_TYPE_ABANDON = 4;  //废弃
    /** 主键*/
    private Long id;
    /** 预约单流水号*/
    private String ano;
    /** 预约单状态 （预约中/履行中/消费中/归档/废弃单）*/
    private Integer status;

    public String getAppointmentStatus() {
        switch (status) {
            case STATUS_TYPE_APPOINT : return "预约中";
            case STATUS_TYPE_PERFORM : return "履行中";
            case STATUS_TYPE_CONSUME : return "消费中";
            case STATUS_TYPE_PLACEON : return "归档中";
            case STATUS_TYPE_ABANDON : return "废弃";
            default:return "未知";
        }
    }

    /** 业务大类*/
   // private Long categoryId;
    private SystemDictionary category;
    /** 预约说明*/
    private String info;
    /** 联系电话*/
    private String contactTel;
    /** 联系人名称*/
    private String contactName;
    /** 预约门店*/
   // private Long businessId;
    private Business business;
    /** 创建时间*/
    private Date createTime;
    /** 预约时间*/
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date appointmentTime;

    public String toJson() {
        HashMap<Object, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("status", status);
        map.put("ano", ano);
        map.put("categoryId", category.getId());
        map.put("categoryParentId", category.getParentId());
        map.put("info", info);
        map.put("contactTel", contactTel);
        map.put("contactName", contactName);
        map.put("businessId", business.getId());
        map.put("appointmentTime", new SimpleDateFormat("yyyy-MM-dd").format(appointmentTime));

        return JSON.toJSONString(map);
    }

}